package com.dengxiujun.simpletomcat.servlet;

import com.dengxiujun.simpletomcat.request.HttpRequest;
import com.dengxiujun.simpletomcat.response.HttpResponse;

import java.io.IOException;

/**
 * <p></p>
 *
 * @author dengxiujun
 * @date 2021-04-26
 **/
public abstract class HttpServlet {

    public void service(HttpRequest req, HttpResponse rep) throws IOException {
        if ("GET".equals(req.getMethod())) {
            doGet(req, rep);
        } else if ("POST".equals(req.getMethod())) {
            doPost(req, rep);
        }
    }

    public abstract void doGet(HttpRequest req, HttpResponse rep) throws IOException;

    public abstract void doPost(HttpRequest req, HttpResponse rep) throws IOException;

}
